// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

// Copyright (C) 2010 David Teeder, All Rights Reserved.
// www.davidteeder.co.uk
// Based on MgcOglRenderer by Magic Software, Inc.

// DXUTRenderer for WildMagic 2.0 3D Game Engine.

#ifndef WEREWULFRENDERER9_H
#define WEREWULFRENDERER9_H

#include <windows.h>
#include "WerewulfCamera.h"
#include "MgcRenderer.h"


class WerewulfRenderer9 : public MgcRenderer
{
   MgcDeclareRTTI;

public:
    // construction and destruction
    WerewulfRenderer9 (HWND hWnd, int iWidth, int iHeight);
    virtual ~WerewulfRenderer9 ();

    void GetDriverInformation ();

    virtual void SetBackgroundColor (const MgcColor& rkColor);
    virtual void ClearBackBuffer ();
    virtual void DisplayBackBuffer ();
    virtual void ClearZBuffer ();
    virtual void ClearBuffers ();

    virtual void Draw (const MgcTriMesh& rkMesh);
    virtual void Draw (const MgcParticles& rkParticle);
    virtual void Draw (const MgcPolyline& rkLine);
    virtual void Draw (const MgcPolypoint& rkPoint);
    virtual void Draw (int iX, int iY, const char* acText);

    // for use in deferred renderer creation when loading renderer from stream
    WerewulfRenderer9 ();
    void CreateRenderer (HWND hWnd);

protected:
    // state management
    virtual void InitializeState ();
    virtual void SetAlphaState (MgcAlphaState* pkState);
    virtual void SetDitherState (MgcDitherState* pkState);
    virtual void SetFogState (MgcFogState* pkState);
    virtual void SetLightState (MgcLightState* pkState);
    virtual void SetMaterialState (MgcMaterialState* pkState);
    virtual void SetShadeState (MgcShadeState* pkState);
    virtual void SetTextureState (MgcTextureState* pkState);
    virtual void SetVertexColorState (MgcVertexColorState* pkState);
    virtual void SetWireframeState (MgcWireframeState* pkState);
    virtual void SetZBufferState (MgcZBufferState* pkState);

    // window parameters
    HWND m_hWnd;
    HDC m_hWindowDC;
    HGLRC m_hWindowRC;

	/*
    // maps from Magic enums to OpenGL enums
    static GLenum ms_aeAlphaSrcBlend[MgcAlphaState::SBF_QUANTITY];
    static GLenum ms_aeAlphaDstBlend[MgcAlphaState::DBF_QUANTITY];
    static GLenum ms_aeAlphaTest[MgcAlphaState::TF_QUANTITY];
    static GLenum ms_aeFogDensity[MgcFogState::DF_QUANTITY];
    static GLenum ms_aeFogApply[MgcFogState::AF_QUANTITY];
    static GLenum ms_aeShade[MgcShadeState::SM_QUANTITY];
    static GLenum ms_aeTextureCorrection[MgcTexture::CM_QUANTITY];
    static GLenum ms_aeTextureApply[MgcTexture::AM_QUANTITY];
    static GLenum ms_aeTextureFilter[MgcTexture::FM_QUANTITY];
    static GLenum ms_aeTextureMipmap[MgcTexture::MM_QUANTITY];
    static GLenum ms_aeImageComponents[MgcImage::IT_QUANTITY];
    static GLenum ms_aeImageFormats[MgcImage::IT_QUANTITY];
    static GLenum ms_aeZBufferCompare[MgcZBufferState::CF_QUANTITY];
	*/
    // for debugging
    bool OperationOkay ();
};

MgcSmartPointer(WerewulfRenderer9);

#endif
